<template>
  <div>
    <el-form id="form" ref="form" :model="goods"  label-width="80px"
             label-position="right"  size="mini">
      <el-form-item label="类别" prop="g_name" >
        <el-input v-model="goods.g_name"></el-input>
      </el-form-item>

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="save" size="mini">确定</el-button>
    </div>
  </div>
</template>

<script>
    export default {
        name: "GoodsUpdate",
      data(){
          return{
            goods:{
              g_name:'',
              g_id:''
            }
          }
      },
      methods:{
        save(){
          this.$axios.post("GoodsServlet/updateGoods?g_id=" + this.goods.g_id +'&g_name='+this.goods.g_name)
            .then(resp=>{
              this.$router.push('/goods/list')
            })
        }
      },
      created() {
        this.$axios.get('GoodsServlet/findGoodsById?g_id=' + this.$route.params.id)
          .then(resp=>{
            this.goods = resp.data
          })
      }
    }
</script>

<style scoped>

</style>
